package com.ruoyi.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.annotation.DataSource;
import com.ruoyi.common.enums.DataSourceType;
import com.ruoyi.system.domain.OtherRoomEventConfig;
import com.ruoyi.system.domain.OtherTakeLeaveConfig;
import com.ruoyi.system.mapper.OtherRoomEventConfigMapper;
import com.ruoyi.system.mapper.OtherTakeLeaveMapper;
import com.ruoyi.system.service.IOtherRoomEventConfigService;
import com.ruoyi.system.service.IOtherTakeLeaveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@DataSource(value = DataSourceType.SLAVE)
public class OtherTakeLeaveConfigServiceImpl extends ServiceImpl<OtherTakeLeaveMapper, OtherTakeLeaveConfig> implements IOtherTakeLeaveService {

    @Autowired
    private OtherTakeLeaveMapper otherTakeLeaveMapper;

    @DataSource(value = DataSourceType.SLAVE)
    public OtherTakeLeaveConfig getTakeLeaveConfigByRoomID(String roomID) {
        return otherTakeLeaveMapper.selectOne(new LambdaQueryWrapper<OtherTakeLeaveConfig>().eq(OtherTakeLeaveConfig::getRoomID, roomID));
    }

    @DataSource(value = DataSourceType.SLAVE)
    public int updateTakeLeaveConfigByRoomID(OtherTakeLeaveConfig otherTakeLeaveConfig) {
        return otherTakeLeaveMapper.updateById(otherTakeLeaveConfig);
    }
}
